package pCloud.service;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

public class Test {
	public static void main(String[] args) throws InstantiationException,
			IllegalAccessException, ClassNotFoundException, SQLException {
		Class.forName("com.mysql.jdbc.Driver").newInstance();
		Connection connection = DriverManager.getConnection(
				"jdbc:mysql://localhost:3306/weather", "root", "ntu2011");
		Statement st = connection.createStatement();
		ResultSet rs = st.executeQuery("describe intellisys_record");
		int c = rs.getMetaData().getColumnCount();
		
		while (rs.next()){
			for (int i=1; i<=c; i++)
			System.out.print(rs.getString(i)+"\t");
			System.out.println();
		}
//		DatabaseMetaData dmd = connection.getMetaData();
//		ResultSet ss = dmd.getSchemas();
//		System.out.println("schema > 1 "+ss.next());
//		while (ss.next()) {
//			System.out.println(ss);
//			if (ss.getString(1).equals("public")) {
//				ResultSet rs = dmd.getTables(null, ss.getString(1), "%", null);
//				
//				while (rs.next()){					
//					System.out.println(rs.getString(3));
//				}
//			}
//		}
		
		//ResultSet rs = dmd.getColumns(null, "public", "temp", null);
//		while (rs.next()){
//				System.out.println(rs.getString(4)+"\t "+rs.getString(6));
//			//System.out.println();
//		}
		// ResultSet rs = dmd.getTables(null, "", "%", null);

	}
}
